/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hu
 * Date: 2024-04-25
 * Time: 23:02
 */
public class Test {
    public static void main2(String[] args) {
        //法1 for循环


                int count = 0;//记录9出现的次数
                for (int i = 1; i <=100 ; i++) {
                    if(i%10==9){//计算90以内的数，包括99
                        count++;
                    }
                    if(i/10==9){//计算90以上的数
                        count++;
                    }
                }
                System.out.println("一共出现："+count+"个");
            }


    public static void main(String[] args) {
        //100中有几个9
        int sum = 0;
        for (int i = 1; i <=  100; i++) {
            if(i % 10 == 9){
                sum++;
            }else if(i / 10 == 9){
                sum++;
            }
        }
        System.out.println(sum);
    }
}
